#include "vector_line.h"

VectorLine::VectorLine(Area *src, Area *dest) :
	_src(src), _dest(dest)
{
}

void VectorLine::draw(QPaintDevice *area)
{
    QPainter *painter = new QPainter();
    painter->begin(area);
    	QColor lineColor = QColor(0, 127, 85);
    	int lineWidth = 2;
        painter->setPen(QPen( lineColor, lineWidth ));
        painter->drawLine(
        		_src->x()+_src->width()/2,
                _src->y()+_src->height()/2,
                _dest->x()+_dest->width()/2,
                _dest->y()+_dest->height()/2 );
    painter->end();
    delete painter;
}

QByteArray VectorLine::contains() const
{
    return "<object type=line src="+
            QByteArray::number(_src->serial())+
            " dest="+
            QByteArray::number(_dest->serial())+
            ">|</object>\n";
}

bool VectorLine::isEqual(Area *src, Area *dest) const
{
    return (_src == src && _dest == dest);
}

Area *VectorLine::src() const
{
	return _src;
}

Area *VectorLine::dest() const
{
	return _dest;
}
